package org.codefinger.json.parser.deserializer;

import org.codefinger.json.parser.JSONArrayDeserializer;
import org.codefinger.json.parser.JSONDeserializer;
import org.codefinger.json.parser.JSONLexer;
import org.codefinger.json.parser.JSONObjectDeserializer;
import org.codefinger.json.util.Base64;

public class DeserializerForByteArray implements JSONDeserializer {

	public static final DeserializerForByteArray	INSTANCE	= new DeserializerForByteArray();

	private DeserializerForByteArray() {

	}

	
	@Override
	public Object stringValue(String value) {
		return  Base64.decodeFast(value);
	}

	
	@Override
	public Object stringValue(JSONLexer jsonLexer) {
		return  Base64.decodeFast(jsonLexer.getOriginalCharArray());
	}

	
	@Override
	public Object intValue(String value) {
		return  value.getBytes();
	}

	
	@Override
	public Object floatValue(String value) {
		return  value.getBytes();
	}

	
	@Override
	public Object falseValue() {
		return  new byte[] { 102, 97, 108, 115, 101 };
	}

	
	@Override
	public Object trueValue() {
		return  new byte[] { 116, 114, 117, 101 };
	}

	@Override
	public JSONArrayDeserializer createArrayDeserializer() {
		return new ArrayDeserializerForByteArray();
	}

	@Override
	public JSONObjectDeserializer createObjectDeserializer() {
		return ObjectDeserializerForNull.INSTANCE;
	}

}
